let baseUrl
if (process.env.NODE_ENV === 'development') {
	//本地路径
	//baseUrl = '/dpc/';
	// baseUrl = 'https://www.etometa.com/api/'
	 baseUrl = 'https://www.mulang.xin/api/'
} else {
	//线上路径
	 // baseUrl = 'https://www.etometa.com/api/'
	 baseUrl = 'https://www.mulang.xin/api/'
}
const post = (url, data, hideloding) => {

	let token = ''
	try {
		token = uni.getStorageSync("app_token")
	} catch (e) {}

	let httpDefaultOpts = {
		url: baseUrl + url,
		data: data,
		method: "POST",
		header: {
			'Accept': 'application/json',
			'Content-Type': 'application/x-www-form-urlencoded',
			'token': token
		},
		dataType: 'json',
	}
	let promise = new Promise(function(resolve, reject) {
		uni.request(httpDefaultOpts).then(
		
			(res) => {
				resolve(res[1].data)
			}
		)
	})
	return promise
};
const get = (url, data, hideloding) => {
	let httpDefaultOpts = ''
	let token = ''
	try {
		token = uni.getStorageSync("app_token")
	} catch (e) {}
	httpDefaultOpts = {
		url: baseUrl + url,
		method: "GET",
		data: data,
		header: {
			'Accept': 'application/json',
			'Content-Type': 'application/x-www-form-urlencoded',
			'token': token
		},
		dataType: 'json',
	}
	let promise = new Promise(function(resolve, reject) {
		uni.request(httpDefaultOpts).then(
			(res) => {
			    resolve(res[1].data)
			}
		)
	})
	return promise
};
export default {
	post,
	get,baseUrl
}
